package com.zr.eim.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.zr.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zr.common.annotation.Log;
import com.zr.common.core.controller.BaseController;
import com.zr.common.core.domain.AjaxResult;
import com.zr.common.enums.BusinessType;
import com.zr.eim.domain.EimOuterCitizen;
import com.zr.eim.service.IEimOuterCitizenService;
import com.zr.common.utils.poi.ExcelUtil;
import com.zr.common.core.page.TableDataInfo;

/**
 * 外部输入人员Controller
 * 
 * @author haomingxue
 * @date 2022-10-25
 */
@Anonymous
@RestController
@RequestMapping("/eim/citizen")
public class EimOuterCitizenController extends BaseController
{
    @Autowired
    private IEimOuterCitizenService eimOuterCitizenService;

    /**
     * 查询外部输入人员列表
     */
    @PreAuthorize("@ss.hasPermi('eim:citizen:list')")
    @GetMapping("/list")
    public TableDataInfo list(EimOuterCitizen eimOuterCitizen)
    {
        startPage();
        List<EimOuterCitizen> list = eimOuterCitizenService.selectEimOuterCitizenList(eimOuterCitizen);
        return getDataTable(list);
    }

    /**
     * 导出外部输入人员列表
     */
    @PreAuthorize("@ss.hasPermi('eim:citizen:export')")
    @Log(title = "外部输入人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EimOuterCitizen eimOuterCitizen)
    {
        List<EimOuterCitizen> list = eimOuterCitizenService.selectEimOuterCitizenList(eimOuterCitizen);
        ExcelUtil<EimOuterCitizen> util = new ExcelUtil<EimOuterCitizen>(EimOuterCitizen.class);
        util.exportExcel(response, list, "外部输入人员数据");
    }

    /**
     * 获取外部输入人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('eim:citizen:query')")
    @GetMapping(value = "/{pid}")
    public AjaxResult getInfo(@PathVariable("pid") Long pid)
    {
        return AjaxResult.success(eimOuterCitizenService.selectEimOuterCitizenByPid(pid));
    }

    /**
     * 新增外部输入人员
     */
    @PreAuthorize("@ss.hasPermi('eim:citizen:add')")
    @Log(title = "外部输入人员", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody EimOuterCitizen eimOuterCitizen)
    {
        return toAjax(eimOuterCitizenService.insertEimOuterCitizen(eimOuterCitizen));
    }

    /**
     * 新增外部输入人员
     */
    @Log(title = "外部输入人员", businessType = BusinessType.INSERT)
    @PostMapping("/addMobil")
    public AjaxResult addMobil(EimOuterCitizen eimOuterCitizen)
    {
        return toAjax(eimOuterCitizenService.insertEimOuterCitizen(eimOuterCitizen));
    }
    /**
     * 修改外部输入人员
     */
    @PreAuthorize("@ss.hasPermi('eim:citizen:edit')")
    @Log(title = "外部输入人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EimOuterCitizen eimOuterCitizen)
    {
        return toAjax(eimOuterCitizenService.updateEimOuterCitizen(eimOuterCitizen));
    }

    /**
     * 删除外部输入人员
     */
    @PreAuthorize("@ss.hasPermi('eim:citizen:remove')")
    @Log(title = "外部输入人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pids}")
    public AjaxResult remove(@PathVariable Long[] pids)
    {
        return toAjax(eimOuterCitizenService.deleteEimOuterCitizenByPids(pids));
    }


    /**
     * 查询七日内入境人数及境外输入病例数
     * 需求模块：数据大屏
     */
    @PreAuthorize("@ss.hasPermi('eim:citizen:query')")
    @PostMapping("/getOuterCitizen")
    public AjaxResult getOuterCitizen()
    {
        return AjaxResult.success(eimOuterCitizenService.getOuterCitizen());
    }

    @PreAuthorize("@ss.hasPermi('eim:citizen:query')")
    @PostMapping("/getOuterDiagnostic")
    public AjaxResult getOuterDiagnostic()
    {
        return AjaxResult.success(eimOuterCitizenService.getOuterDiagnostic());
    }
}
